<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>预警系统-用户管理</title>
<link rel="stylesheet" type="text/css"
	href="/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="/themes/icon.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/eui_manager.js"></script>
<script type="text/javascript" src="/js/util.js"></script>
</head>
<body>
	<ul id="nav"></ul>
	<div id="cc" class="easyui-layout" style="width: 100%; height: 700px;">
		<div data-options="region:'center'">
			<div style="margin: 10px;">
				<label for="group">分组</label><input id="group" name="group" value="">
				<label for="manager">负责人</label><input id="manager" name="manager"
					value="">
				<button onclick="reloadUserTable()">查询</button>
			</div>
			<table id="dg"></table>
		</div>
	</div>
	<div id="tb" style="height: auto">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			data-options="iconCls:'icon-add',plain:true"
			onclick="action.insert()">添加</a>
	</div>

	<script type="text/javascript">
		var url = '/ui/';
		var tbl = $('#dg');
		var clsName = 'com.itrip.log.module.db.domain.EmailGroup';
		var action = new UIAction(tbl, clsName, url, getFormVal);

		function getFormVal() {
			var arr = {
				'groupName' : Util.getCombobox('#group'),
				'manager' : Util.getCombobox('#manager'),
			};
			return arr;
		}

		function reloadUserTable() {
			$('#dg').datagrid('reload');
		}

		$(function() {
			
			var grp = $.ajax({
				url : "/ui/select?id=queryUserGroup",
				async : false
			}).responseJSON;

			var mgrs = $.ajax({
				url : "/ui/select?id=queryUserManager",
				async : false
			}).responseJSON;

			var columns = [ [ {
				field : 'id',
				title : 'ID',
				width : '15%',
			}, {
				field : 'name',
				title : '名称',
				width : '15%',
				editor : 'textbox'
			}, {
				field : 'email',
				title : '邮箱',
				width : '15%',
				editor : 'textbox'
			}, {
				field : 'groupName',
				title : '分组',
				width : '15%',
				editor : {
					type : 'combobox',
					options : {
						data : grp,
						editable:true,
						textField : "name",
						valueField : "name"
					}
				}
			}, {
				field : 'manager',
				title : '负责人',
				width : '15%',
				editable : "false",
				editor : {
					type : 'combobox',
					options : {
						data : mgrs,
						editable:true,
						textField : "name",
						valueField : "name",
					}
				}
			}, {
				field : 'action',
				title : '操作',
				width : '15%',
				formatter : action.buildAction
			} ] ];

			Util.builCombVal('#group', grp, 'name', 'name');
			Util.builCombVal('#manager', mgrs, 'name', 'name');

			initNavMenu('#nav');
			action.configTable('#tb', columns);
		})
	</script>
</body>
</html>
